﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using zichan.Entity;
using zichan.BLL;
using zichan.Models;
using AutoMapper;
using System.Configuration;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace zichan.Controllers
{
    public class AssetesController : BaseController
    {
        // GET: Assetes
        public ActionResult Index(string code, string name, int? assetClassId, int? companyId, DateTime? sdt, DateTime? edt, int? page, int? pageSize, int? pageCount, int? selectedPage)
        {
            page = page ?? 1;

            pageSize = pageSize ?? 10;
            if (selectedPage.HasValue)
                page = selectedPage;
            if (pageCount.HasValue)
                page = page <= pageCount ? page : pageCount;
            if (page < 1) page = 1;
            ViewBag.page = page;
            ViewBag.pageSize = pageSize;
            ViewBag.selectedPage = selectedPage;
            List<SelectListItem> items = new List<SelectListItem> { new SelectListItem { Value = "10", Text = "10" }, new SelectListItem { Value = "20", Text = "20" }, new SelectListItem { Value = "50", Text = "50" }, new SelectListItem { Value = "100", Text = "100" } };
            ViewBag.pageSizes = new SelectList(items, "Value", "Text", ViewBag.pageIndex);

            ViewBag.assetClassIds = new SelectList(AsseteClassService.GetAsseteClassList(string.Empty, string.Empty), "Id", "Name", assetClassId);
            ViewBag.assetClassId = assetClassId;
            ViewBag.companyIds = new SelectList(CompanyClassService.GetCompanyList(), "Id", "Name", companyId);
            ViewBag.companyId = companyId;
            ViewBag.sdt = sdt;
            ViewBag.edt = edt;
            ViewBag.code = code;
            ViewBag.name = name;
            List<SelectListItem> checkBox = new List<SelectListItem> { new SelectListItem { Value = "1", Text = "批量入库" }, new SelectListItem { Value = "2", Text = "批量删除" } };
            ViewBag.checkBoxs = new SelectList(checkBox, "Value", "Text");
            if (sdt.HasValue)
                ViewBag.sdt = string.Format("{0:yyyy/M/d}", sdt);
            if (edt.HasValue)
                ViewBag.edt = string.Format("{0:yyyy/M/d}", edt);

            return View(AssetService.List(name, code, assetClassId, companyId, sdt, edt, pageSize.Value, page.Value));
        }
        public ActionResult Create()
        {
            ViewBag.AssetClassId = new SelectList(AsseteClassService.GetAsseteClassList(string.Empty, string.Empty), "Id", "Name");
            ViewBag.CompanyId = new SelectList(CompanyClassService.GetCompanyList(), "Id", "Name");
            ViewBag.BuyerId = new SelectList(StaffService.StaffAll(1), "Id", "Name");
            ViewBag.Recipient = new SelectList(StaffService.StaffAll(1), "Id", "Name");
            List<string> ss = new List<string> { AsseteClassService.GetAsseteClass(1).Identity, AsseteClassService.GetAsseteClass(1).SubIdentity };
            ViewBag.Identitys = ss;

            return View();
        }
        [HttpPost]
        public ActionResult Create(AssetModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.AssetClassId = new SelectList(AsseteClassService.GetAsseteClassList(string.Empty, string.Empty), "Id", "Name", model.AssetClassId);
                ViewBag.CompanyId = new SelectList(CompanyClassService.GetCompanyList(), "Id", "Name", model.CompanyId);
                ViewBag.BuyerId = new SelectList(StaffService.StaffAll(1), "Id", "Name", model.BuyerId);
                ViewBag.Recipient = new SelectList(StaffService.StaffAll(1), "Id", "Name", model.Recipient);
                List<string> ss = new List<string> { AsseteClassService.GetAsseteClass(1).Identity, AsseteClassService.GetAsseteClass(1).SubIdentity };
                ViewBag.Identitys = ss;
                return View(model);
            }
            //model.UploadTime = DateTime.Now;

            var mapperconfig = new MapperConfiguration(cfg => { cfg.CreateMap<AssetModel, zichan.Entity.Asset>(); });
            IMapper mapper = mapperconfig.CreateMapper();
            zichan.Entity.Asset asset = mapper.Map<AssetModel, zichan.Entity.Asset>(model);
            List<int> ids = AssetService.AddAsset(asset);
            List<UsageLog> usageList = new List<UsageLog>();
            string remark = model.Remark;
            List<string> codes = new List<string>();
            if (!string.IsNullOrEmpty(model.Identitys) && model.AssetClassId == 1)
            {
                foreach (int i in ids)
                {
                    string s = null;
                    s = model.Identitys + DateTime.Now.Year + i.ToString().PadLeft(4, '0');
                    codes.Add(i + "#" + s.ToString());
                    UsageLog usageLog = new UsageLog();
                    usageLog.AssetClassId = asset.AssetClassId;
                    usageLog.Time = DateTime.Now;
                    usageLog.AssetId = i;
                    usageLog.Code = s.ToString();
                    usageLog.Operation = "添加";
                    usageLog.Remark = remark;
                    usageList.Add(usageLog);
                }
            }
            else
            {
                string identity = AsseteClassService.GetAsseteClass(model.AssetClassId).Identity;
                foreach (int i in ids)
                {
                    string s = null;
                    s = identity + DateTime.Now.Year + i.ToString().PadLeft(4, '0');
                    codes.Add(i + "#" + s.ToString());
                    UsageLog usageLog = new UsageLog();
                    usageLog.AssetClassId = asset.AssetClassId;
                    usageLog.Time = DateTime.Now;
                    usageLog.AssetId = i;
                    usageLog.Code = s.ToString();
                    usageLog.Operation = "添加";
                    usageLog.Remark = remark;
                    usageList.Add(usageLog);
                }
            }
            string constr = ConfigurationManager.ConnectionStrings["ZichanDBContext"].ConnectionString;
            string codeIds = string.Join(",", codes);
            string err = AssetService.AddCodes(codeIds, constr);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#添加成功";
                UsageLogService.AddList(usageList);
            }
            else
            {
                TempData["alert"] = "error#" + err;
            }
            return RedirectToAction("Index");

        }
        public ActionResult Delete(int id)
        {
            string err = AssetService.Remove(id);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#删除成功";
            }
            else
            {
                TempData["alert"] = "error#" + err;
            }
            return RedirectToAction("Index");
        }
        public ActionResult ImproveInformation(int id)
        {
            zichan.Entity.Asset model = AssetService.Get(id);
            return View(model);
        }
        public ActionResult part_ImproveInformation(int id, int assetId)
        {
            List<ConsumateInfo> list = new List<ConsumateInfo>();
            List<AsseteField> fields = FieldsService.List(id);
            foreach (AsseteField a in fields)
            {
                ConsumateInfo model = new ConsumateInfo();
                model.FieldId = a.Id;
                model.FieldName = a.Name;
                model.AssetId = assetId;
                list.Add(model);
            }
            return PartialView(list);
        }
        [HttpPost]
        public ActionResult part_ImproveInformation(List<string> FieldContent, List<int> FieldId, List<string> FieldName, List<int> AssetId, string identification)
        {
            if (Session["identify"] != null && Session["identify"].ToString() == identification)
            {
                TempData["alert"] = "sorry#" + "相同字段信息不能重复提交";
                return RedirectToAction("Information", new { id = AssetId[0] });
            }
            Session["identify"] = identification;
            List<ConsumateInfo> list = new List<ConsumateInfo>();
            for (int i = 0; FieldContent.Count > i; i++)
            {
                ConsumateInfo model = new ConsumateInfo();
                model.FieldContent = FieldContent[i];
                model.FieldId = FieldId[i];
                model.FieldName = FieldName[i];
                model.AssetId = AssetId[i];
                list.Add(model);

            }
            string err = ConsumateInfoService.AddFieldsList(list);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#信息已完善";
                UsageLogService.AddBaseToId(AssetId[0]);
            }
            else
            {
                TempData["alert"] = "error#" + err;
            }
            return RedirectToAction("Information", new { id = AssetId[0] });
        }
        public ActionResult serverPart_ImproveInformation(int id)
        {
            ViewBag.Staffs = new SelectList(StaffService.StaffAll(1), "ID", "Name");
            ViewBag.id = id;
            return PartialView();
        }
        [HttpPost]
        public ActionResult serverPart_ImproveInformation(ServerInfo model)
        {
            if (!ModelState.IsValid)
            {
                TempData["alert"] = "error#请重新填写数据，带*为必填";
                return RedirectToAction("ImproveInformation", new { id = model.AssetId });
            }

            string err = ServerInfoService.Add(model);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#信息已完善";
                UsageLogService.AddBaseToId(model.AssetId);
            }
            else
            {
                TempData["alert"] = "error#" + err;
                return View();
            }
            return RedirectToAction("Information", new { id = model.AssetId });
        }
        public ActionResult editServerPart_ImproveInformation(int id)
        {
            ServerInfo model = ServerInfoService.Get(id);
            ViewBag.Staffs = new SelectList(StaffService.StaffAll(1), "ID", "Name", model.AdminiStratorId);
            ViewBag.id = id;
            return PartialView(model);
        }
        [HttpPost]
        public ActionResult editServerPart_ImproveInformation(ServerInfo model)
        {
            if (!ModelState.IsValid)
            {
                TempData["alert"] = "error#请重新填写数据，带*为必填";
                return RedirectToAction("Information", new { id = model.AssetId });
            }

            string err = ServerInfoService.Edit(model);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#信息已修改";
                UsageLogService.AddBaseToId(model.AssetId);
            }
            else
            {
                TempData["alert"] = "error#无法修改";
                return View();
            }
            return RedirectToAction("Information", new { id = model.AssetId });
        }
        public ActionResult Information(int id)
        {
            zichan.Entity.Asset model = AssetService.Get(id);
            return View(model);
        }
        public ActionResult editPart_ImproveInformation(int assetId)
        {
            List<ConsumateInfo> list = new List<ConsumateInfo>();
            list = ConsumateInfoService.GetList(assetId);
            return PartialView(list);
        }
        [HttpPost]
        public ActionResult editPart_ImproveInformation(List<string> FieldContent, List<int> FieldId, List<string> FieldName, List<int> AssetId, List<int> Id)
        {
            List<ConsumateInfo> list = new List<ConsumateInfo>();
            for (int i = 0; FieldContent.Count > i; i++)
            {
                ConsumateInfo model = new ConsumateInfo();
                model.FieldContent = FieldContent[i];
                model.FieldId = FieldId[i];
                model.FieldName = FieldName[i];
                model.AssetId = AssetId[i];
                model.Id = Id[i];
                list.Add(model);

            }
            string err = ConsumateInfoService.EditFieldList(list);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#信息已修改";
                UsageLogService.AddBaseToId(AssetId[0]);
            }
            else
            {
                TempData["alert"] = "error#" + err;
            }
            return RedirectToAction("Information", new { id = AssetId[0] });
        }
        [HttpPost]
        public ActionResult Put(int id)
        {
            zichan.Entity.Asset model = AssetService.Get(id);
            model.StatusTime = DateTime.Now;
            model.Status = 1;
            string err = AssetService.Edit(model);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#入库成功";
                UsageLog usageLog = new UsageLog();
                usageLog.AssetClassId = model.AssetClassId;
                usageLog.Code = model.Code;
                usageLog.Time = DateTime.Now;
                usageLog.Operation = "新增入库";
                usageLog.AssetId = model.Id;
                UsageLogService.Add(usageLog);
                return Json(new { result = 0 });
            }
            else
            {
                TempData["alert"] = "error#入库失败";
                return Json(new { result = 1 });
            }

        }
        [HttpPost]
        public ActionResult BatchPut(string ids)
        {
            List<string> idList = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            ids = string.Join(",", idList);
            string constr = ConfigurationManager.ConnectionStrings["ZichanDBContext"].ConnectionString;
            string err = AssetService.PutBatch(ids, constr);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#批量添加成功";
                UsageLogService.AddTemList(idList);
            }
            else
            {
                TempData["alert"] = "error#" + err;
            }
            return Json(new { result = 0 });
        }
        [HttpPost]
        public ActionResult BatchDelete(string ids)
        {
            List<string> idList = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            ids = string.Join(",", idList);
            string constr = ConfigurationManager.ConnectionStrings["ZichanDBContext"].ConnectionString;
            string err = AssetService.DeleteBatch(ids, constr);
            if (string.IsNullOrEmpty(err))
            {
                TempData["alert"] = "success#批量sc成功";
            }
            else
            {
                TempData["alert"] = "error#" + err;
            }
            return Json(new { result = 0 });
        }
        #region//旧数据部分，用完需删
        public ActionResult oldAssetCreate()
        {
            List<string> ss = new List<string> { AsseteClassService.GetAsseteClass(1).Identity, AsseteClassService.GetAsseteClass(1).SubIdentity };
            ViewBag.Identitys = ss;
            //ViewBag.BuyerId = new SelectList(StaffService.StaffAll(1), "Id", "Name");
            //ViewBag.Recipient = new SelectList(StaffService.StaffAll(1), "Id", "Name");
            return View();
        }
        [HttpPost]
        public ActionResult oldAssetCreate(oldAssetModel model)
        {
            if (!ModelState.IsValid)
            {
                List<string> ss = new List<string> { AsseteClassService.GetAsseteClass(1).Identity, AsseteClassService.GetAsseteClass(1).SubIdentity };
                ViewBag.Identitys = ss;
                //ViewBag.BuyerId = new SelectList(StaffService.StaffAll(1), "Id", "Name",model.BuyerId);
                //ViewBag.Recipient = new SelectList(StaffService.StaffAll(1), "Id", "Name",model.Recipient);
                return View(model);
            }
            BinaryFormatter bf = new BinaryFormatter();
            using (Stream str = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "oldAsset.dat", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                bf.Serialize(str, model);
            }
            return RedirectToAction("Index");
        }
        public ActionResult oldInfoCreate()
        {
            ViewBag.Staffs = new SelectList(StaffService.StaffAll(1), "ID", "Name");
            return View();
        }
        [HttpPost]
        public ActionResult oldInfoCreate(oldServerInfo model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Staffs = new SelectList(StaffService.StaffAll(1), "ID", "Name", model.AdminiStratorId);
                return View(model);
            }
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            using (Stream stream = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "oldServerInfo.dat", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                binaryFormatter.Serialize(stream, model);
            }

            return RedirectToAction("Index");
        }


        public ActionResult AssetAndPutServer()
        {
            ViewBag.Staffs = new SelectList(StaffService.StaffAll(1), "ID", "Name");
            //ViewBag.id = id;
            //ViewBag.AssetClassId = new SelectList(AsseteClassService.GetAsseteClassList(string.Empty, string.Empty), "Id", "Name");
            ViewBag.CompanyId = new SelectList(CompanyClassService.GetCompanyList(), "Id", "Name");
           
            List<string> ss = new List<string> { AsseteClassService.GetAsseteClass(1).Identity, AsseteClassService.GetAsseteClass(1).SubIdentity };
            ViewBag.Identitys = ss;
            ViewBag.machineRoomIds = new SelectList(MachineRoomService.List(), "Id", "Name");
            List<SelectListItem> cItems = new List<SelectListItem>();
            ViewBag.cabinetIds = new SelectList(cItems);
            ViewBag.cabinetClassIds = new SelectList(CabinetClassService.List(), "Id", "Purpose");
            ViewBag.ipIds = new SelectList(IPService.NoUseList(), "Id", "Ip");
            ViewBag.subIpIds = new SelectList(IPService.NoUseList(), "Id", "Ip");
            ViewBag.serverPurposeIds = new SelectList(ServerPurposeService.GetList(), "serverPurposeId", "serverPurposeName");
            List<SelectListItem> uNO = new List<SelectListItem>();
            ViewBag.uNOs = new SelectList(uNO);
            //List<SelectListItem> code = new List<SelectListItem>();
            //ViewBag.Codes = new SelectList(code);
            //CabinetClass c = CabinetClassService.GetCabinetClass(1);
            //ViewBag.serverPurposes = new SelectList(ServerPurposeService.GetList());
            ServerPurposeSubClass c = ServerPurposeSubClassService.Get(1);
            List<SelectListItem> citems = new List<SelectListItem> { new SelectListItem { Value = c.IsSendProperty, Text = "送产权" }, new SelectListItem { Value = c.IsNoProperty, Text = "无产权" } };
            ViewBag.Propertys = new SelectList(citems, "Value", "Text");
            //CabinetClass Tc = CabinetClassService.GetCabinetClass(2);
            ServerPurposeSubClass Tc = ServerPurposeSubClassService.Get(2);
            List<SelectListItem> Tcitems = new List<SelectListItem> { new SelectListItem { Value = Tc.IsSendProperty, Text = "送产权" }, new SelectListItem { Value = Tc.IsNoProperty, Text = "无产权" } };
            ViewBag.TPropertys = new SelectList(Tcitems, "Value", "Text");
            return View();
        }
        [HttpPost]
        public ActionResult AssetAndPutServer(BLL.StatisticsModel.OldServerModel model)
        {
            bool modelState = !ModelState.IsValid;
            ViewBag.Staffs = new SelectList(StaffService.StaffAll(1), "ID", "Name",modelState? model.AdminiStratorId:0);
            //ViewBag.id = id;
            //ViewBag.AssetClassId = new SelectList(AsseteClassService.GetAsseteClassList(string.Empty, string.Empty), "Id", "Name");
            ViewBag.CompanyId = new SelectList(CompanyClassService.GetCompanyList(), "Id", "Name", modelState ? model.CompanyId:0);
            //ViewBag.BuyerId = new SelectList(StaffService.StaffAll(1), "Id", "Name", modelState ? model.BuyerId:0);
            //ViewBag.Recipient = new SelectList(StaffService.StaffAll(1), "Id", "Name", modelState ? model.Recipient:0);
            List<string> ss = new List<string> { AsseteClassService.GetAsseteClass(1).Identity, AsseteClassService.GetAsseteClass(1).SubIdentity };
            ViewBag.Identitys = ss;
            ViewBag.machineRoomIds = new SelectList(MachineRoomService.List(), "Id", "Name", modelState ? model.MachineRoomId:0);
            if (model.MachineRoomId != 0)
                ViewBag.cabinetIds = new SelectList(CabinetManageService.CabinetList(model.MachineRoomId), "Id", "Name", modelState ? model.CabinetId:0);
            else
            {
                List<SelectListItem> cItems = new List<SelectListItem>();
                ViewBag.cabinetIds = new SelectList(cItems);
            }
            //ViewBag.companyIds = new SelectList(CompanyClassService.GetCompanyList(), "Id", "Name");
            ViewBag.cabinetClassIds = new SelectList(CabinetClassService.List(), "Id", "Purpose", modelState ? model.PurposeId:0);
            ViewBag.ipIds = new SelectList(IPService.NoUseList(), "Id", "Ip", modelState ? model.IPId:0);
            ViewBag.subIpIds = new SelectList(IPService.NoUseList(), "Id", "Ip", modelState ? model.SubIPId:null);
            ViewBag.serverPurposeIds = new SelectList(ServerPurposeService.GetList(), "serverPurposeId", "serverPurposeName");
            //List<SelectListItem> uNO = new List<SelectListItem>();
            //ViewBag.uNOs = new SelectList(uNO);
            //List<SelectListItem> code = new List<SelectListItem>();
            //ViewBag.Codes = new SelectList(code);
            // CabinetClass c = CabinetClassService.GetCabinetClass(1);
            ServerPurposeSubClass c = ServerPurposeSubClassService.Get(1);
            List<SelectListItem> citems = new List<SelectListItem> { new SelectListItem { Value = c.IsSendProperty, Text = "送产权" }, new SelectListItem { Value = c.IsNoProperty, Text = "无产权" } };
            ViewBag.Propertys = new SelectList(citems, "Value", "Text", modelState ? model.Property:null);
            //CabinetClass Tc = CabinetClassService.GetCabinetClass(2);
            ServerPurposeSubClass Tc = ServerPurposeSubClassService.Get(2);
            List<SelectListItem> Tcitems = new List<SelectListItem> { new SelectListItem { Value = Tc.IsSendProperty, Text = "送产权" }, new SelectListItem { Value = Tc.IsNoProperty, Text = "无产权" } };
            ViewBag.TPropertys = new SelectList(Tcitems, "Value", "Text", modelState ? model.TProperty:null);

            if (modelState || model.U_Number > AssetService.oldCabinetNum(model.CabinetId))
            {
                if (model.U_Number > AssetService.oldCabinetNum(model.CabinetId))
                    TempData["alert"] = "error#服务器U数大于机柜架可使用U数";
                TempData["alert"] = "error#带有红色星号的字段为必填字段，请确认数据的完整性";
                return View(model);
            }
            if (model.PurposeId != 1)
            {
                model.Property = null;
            }
            if (model.PurposeId != 2)
            {
                model.TProperty = null;
            }
            var mapperconfigToAsset = new MapperConfiguration(cfg => { cfg.CreateMap<BLL.StatisticsModel.OldServerModel, zichan.Entity.Asset>(); });
            IMapper mapperToAsset = mapperconfigToAsset.CreateMapper();
            zichan.Entity.Asset asset = mapperToAsset.Map<BLL.StatisticsModel.OldServerModel, zichan.Entity.Asset>(model);
            asset.BuyerId = StaffService.GetByName(model.BuyerName.Trim());
            asset.Recipient = StaffService.GetByName(model.RecipientName.Trim());
            asset.UserId = StaffService.GetByName(model.UserName.Trim());
            //asset.serverPurposeId = model.serverPurposeId;
            //asset.serverPurposeSubId = model.serverPurposeSubId;
            int adId = StaffService.GetByName(model.AdminiStratorName);
            if (asset.BuyerId==0||asset.Recipient==0||asset.UserId==0||(adId==0&&!string.IsNullOrEmpty(model.AdminiStratorName)))
            {
                ModelState.AddModelError(asset.BuyerId==0? "BuyerName":asset.Recipient==0? "RecipientName":adId==0 && !string.IsNullOrEmpty(model.AdminiStratorName)? "AdminiStratorName" : "UserName","数据库查无此姓名");
                return View(model);
            }
            
            int id = AssetService.AddOldAsset(asset);
            asset = AssetService.Get(id);
            string err = null;
            if (id != 0)
            {
                var mappconfigToServerInfo = new MapperConfiguration(cfg => { cfg.CreateMap<BLL.StatisticsModel.OldServerModel, zichan.Entity.ServerInfo>(); });
                IMapper mapperToServerInfo = mappconfigToServerInfo.CreateMapper();
                zichan.Entity.ServerInfo serinfo = mapperToServerInfo.Map<BLL.StatisticsModel.OldServerModel, ServerInfo>(model);
                serinfo.AssetId = id;
                serinfo.AdminiStratorId = adId;
               err= ServerInfoService.Add(serinfo);
            }
            if (string.IsNullOrEmpty(err))
            {
                var mapperconfigToPutServer = new MapperConfiguration(cfg => { cfg.CreateMap<BLL.StatisticsModel.OldServerModel, zichan.Entity.PutawayServer>(); });
                IMapper mapperToPutServer = mapperconfigToPutServer.CreateMapper();
                PutawayServer puserver = mapperToPutServer.Map<BLL.StatisticsModel.OldServerModel, PutawayServer>(model);
                puserver.Code = asset.Code;
                puserver.UseNumber = model.U_Number;
                CabinetManageService.AddPutAway(puserver);
            }
            if(!modelState)
            {
                TempData["alert"] = "success#已添加服务器资产并上架";
            }

            ModelState.Clear();
            return View();
        }

        #endregion
    }
}